﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;

namespace ToDoClear
{
    public partial class TestRender : PhoneApplicationPage
    {
        public TestRender()
        {
            InitializeComponent();
            btn1.Height = 70;
            btn2.Height = 70;

            RectangleGeometry  rg=new RectangleGeometry();
            rg.Rect=new Rect(0,0,153,58);
            btn1.Clip = rg;

            RectangleGeometry rg2 = new RectangleGeometry();
            rg2.Rect = new Rect(0,35, 153, 75);
            btn2.Clip = rg2;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            RectangleGeometry rg2 = new RectangleGeometry();
            rg2.Rect = new Rect(0, 10, 153, 75);
            btn2.Clip = rg2;


            /*
            img.Width = 100;
            img.Height = 100;
            img.Stretch = Stretch.None;
            img.Source = Render();
            */

            /*
            Canvas c = new Canvas();
            c.Width = 100;
            c.Height = 100;

            Button testBtn = new Button();
            testBtn.Content = "sdlf";
            c.Children.Add(testBtn);

            WriteableBitmap bmp = new WriteableBitmap(480, 800);
            bmp.Render(c, null);
            bmp.Invalidate();
            img.Source = bmp;*/

        }

        private WriteableBitmap Render()
        {
            Canvas c = new Canvas();
            c.Width = 100;
            c.Height = 100;

            Button testBtn = new Button();
            testBtn.Content = "sdlf";



            c.Children.Add(testBtn);
            LayoutRoot.Children.Add(c);
            c.InvalidateArrange();
            c.InvalidateMeasure();
            WriteableBitmap w=new WriteableBitmap(c, null);
            LayoutRoot.Children.Remove(c);

            return w;
        }


    }
}